package cc.example.mybatislike.service;

import cc.example.mybatislike.db.gorm.GStudentRepository;
import cc.example.mybatislike.db.hermeslink.Member;
import cc.example.mybatislike.db.hermeslink.MemberMapper;
import cc.example.mybatislike.db.hermeslink.SchoolMapper;
import cc.example.mybatislike.db.zeus.entity.ModelFile;
import cc.example.mybatislike.db.zeus.entity.ZeusSpout;
import cc.example.mybatislike.db.gorm.GStudentRepository;
import cc.example.mybatislike.db.hermeslink.Member;
import cc.example.mybatislike.db.hermeslink.MemberMapper;
import cc.example.mybatislike.db.hermeslink.SchoolMapper;
import cc.example.mybatislike.db.zeus.ModelFileRepository;
import cc.example.mybatislike.db.zeus.SpoutMapper;
import cc.example.mybatislike.db.zeus.entity.ModelFile;
import cc.example.mybatislike.db.zeus.entity.ZeusSpout;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
public class QueryService {


  @Autowired
  private GStudentRepository gStudentRepository;

  @Autowired
  private MemberMapper memberMapper;

  @Autowired
  private SchoolMapper schoolMapper;

  @Autowired
  private ModelFileRepository modelFileRepository;

  @Autowired
  private SpoutMapper spoutMapper;


  @Transactional
  public void tran() {
    Member member = new Member();
    member.setUsername("123");
    member.setPasswordHash("123123123");
    member.setUid("12312");
    memberMapper.insert(member);

    ModelFile modelFile = new ModelFile();
    modelFile.setName("asdf");
    modelFile.setModelType("SS");
    modelFile.setCurrentVersion(123);
    modelFile.setCreateUser("sd");
    modelFile.setModifyUser("123");
    modelFileRepository.addFile(modelFile);

    ZeusSpout zeusSpout = new ZeusSpout();
    zeusSpout.setDatasource("da");
    zeusSpout.setName("123");
    zeusSpout.setDatasourceType((byte) 1);
    zeusSpout.setType((byte) 2);
    zeusSpout.setExpansionConfig("{}");
    spoutMapper.insert(zeusSpout);

    log.info("Created: {}", zeusSpout);
  }

}
